<template>
	<view class="mian">

		<view class="top_t">
		</view>
		<Header title="交易记录"></Header>
		<view class="tab">
			<view class="wu">
				物品
			</view>
			<view class="shu">
				数量
			</view>
			<view class="shui">
				水晶
			</view>
		</view>
		<!-- /下方主题内容 -->
		<view class="body">
			<scroll-view lower-threshold="50" @scrolltolower="scrolltolower" style="height: 100%" scroll-y="true">
				<view class="list_son" v-for="(item, index) in datalist" :key="index">
					<view class="left">
						<view class="img">
							<image class="bg_wu" :src="imgurl+item.img" mode="widthFix"></image>
						</view>
						<view class="rig_tit">
							<view class="top">
								{{item.name}}
							</view>
							<view class="time">
								{{$u.timeFormat(item.created_at, 'yyyy-mm-dd hh:MM:ss')}}
							</view>
						</view>
					</view>
					<view class="cent">
						{{item.operation_type==1?'出售':'购入'}}<text>{{item.num}}个</text>
					</view>
					<!-- right2 -->
					<view class="right">
						{{item.operation_type==1?'+':'-'}}{{item.number}}
					</view>
				</view>
				<view v-if="datalist.length==0" class="zanwu">
					<image src="http://img.cpgm.cc/panda/static/duoBao/baiwu.png" class="zaneu_img" mode="widthFix"></image>
					<view class="">
						没有数据哦~
					</view>
				</view>
				<u-loadmore v-else :status="status" :icon-type="iconType" :load-text="loadText" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import config from '@/common/config/index.js'
	export default {
		data() {
			return {
				imgurl: config.imgurl,
				headerimgurl: config.headerimgurl,
				value: '',
				active: 0,
				act: 1,
				value2: '',
				show: false,
				page: 1,
				max_page: 1,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '上拉加载',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
				datalist: [],
				userinfo: '', //用户信息
				rewardshow: false,
				exchangenum: '' //这个是兑换的数量
			}
		},
		onLoad() {
			this.datalist = []
			this.getSilverList();
		},
		methods: {
			// 滚动到底部
			scrolltolower() {
				if (this.page >= this.max_page) {
					this.status = 'nomore'
				} else {
					this.status = 'loading';
					this.page = ++this.page;
					this.getSilverList();
					setTimeout(() => {
						if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
						else this.status = 'loading';
					}, 500)
				}
			},
			// 点击发布出售
			fabuchushou() {
				this.$p.navto('/pages/game/my_Release')
			},
			// 获取水晶明细
			async getSilverList() {
				let res = await this.$http.index.payLogs({
					page: this.page
				})
				this.datalist = [...this.datalist, ...res.data];
				this.max_page = res.page;
				if (this.page >= this.max_page) {
					this.status = 'nomore'
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	* {
		box-sizing: border-box;
	}

	.zanwu {
		font-size: 14px;
		color: #A1A1A1;
		font-weight: 500;
		// margin-top: 20%;
		text-align: center;

		.zaneu_img {
			width: 70%;

		}
	}

	.tab {
		width: 100%;
		height: 45px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 16px;
		font-size: 14px;
		font-family: SourceHanSansCN-Medium, SourceHanSansCN;
		font-weight: 500;
		color: #131314;
	}

	.body {
		height: calc(100vh - 145px);
		width: 100%;
		padding: 16px;
		overflow-y: auto;
		background-color: #fff;

		.list_son {
			width: 100%;
			height: 50px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid rgba(161, 161, 161, 0.12);
			margin-bottom: 10px;

			.right {
				font-size: 13px;
				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
				font-weight: 600;
				color: #9D2323;
			}

			.right2 {
				font-size: 13px;
				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
				font-weight: 600;
				color: #239D4C;
			}

			.cent {
				font-size: 13px;
				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
				font-weight: 600;
				color: #131314;
			}

			.left {
				display: flex;
				align-items: center;

				.img {
					width: 38px;
					height: 38px;
					background: url('http://img.cpgm.cc/panda/static/game/vib.png') no-repeat;
					background-size: 100% 100%;
					display: flex;
					justify-content: center;
					align-items: center;
					margin-right: 10px;

					.bg_wu {
						width: 25px;
						height: 25px;
					}
				}

				.rig_tit {
					.top {
						font-size: 15px;
						font-family: SourceHanSansCN-Medium, SourceHanSansCN;
						font-weight: 600;
						color: #131314;
					}

					.time {
						font-size: 11px;
						font-family: PingFang-SC-Medium, PingFang-SC;
						font-weight: 500;
						color: #696969;
					}
				}
			}
		}
	}

	.mian {
		height: 100vh;
	}

	.top_t {
		position: fixed;
		top: 0;
		height: 750rpx;
		max-width: 480px;
		width: 100%;
		z-index: -1;
		background: linear-gradient(180deg, #EACFB7 0%, #FFFFFF 100%);
	}
</style>